<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="../publics/jstl.jsp" %>
<!DOCTYPE html>
<html>
<head>
    <title>运营管理平台-车辆管理</title>
    <link href="${ctx}/resource/publics/jquery-easyui-1.4.4/themes/default/easyui.css" rel="stylesheet" type="text/css">
    <link href="${ctx}/resource/publics/jquery-easyui-1.4.4/themes/icon.css" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="${ctx}/resource/publics/jquery-easyui-1.4.4/jquery.min.js"></script>
    <script type="text/javascript" src="${ctx}/resource/publics/jquery-easyui-1.4.4/jquery.easyui.min.js"></script>
    <script type="text/javascript">
        //修改模糊查询方式
        $.fn.combobox.defaults.filter = function(q, row){
            var opts = $(this).combobox('options');
            return row[opts.textField].indexOf(q) >= 0;
        }
    </script>
</head>
<body>
<table id="dg" title="" style="width:100%"></table>

<div id="showBigImage" style="position:absolute;display:none;border:1px solid silver;background:silver;z-index:9999999;">
    <img src="" style="max-height:180px;" />
</div>
<%
      String type = request.getParameter("type");   //获取url中的参数值
%>
<script type="text/javascript">
$('#dg').datagrid({
    title:'车辆管理',
    border:false,
    fit:true,
    fitColumns:false,
    scrollbarSize:18,
    singleSelect:true,
    method:'post',
    url:'${ctx}/manage/cartype/getCarListType?type='+<%=type%>,
    idField:'id',
    toolbar:'#tb',
    pagination: true,
    columns:[[
        {field:'id',title:'车辆ID',align:'center',width:45},
        {field:'name',title:'车辆名称',align:'center',width:100},
        {field:'description',title:'车辆描述',align:'center',width:200},
        {field:'deviceNumber',title:'设备ID',align:'center',width:180},
        {field:'deviceId1',title:'定位',align:'center',width:80,formatter: function(value,row,index){

            if(row.deviceNumber!=null && row.deviceNumber.length >0) {
                var p = '<a style="margin-left: 5px;" href="javascript:void(0);" onclick="DW(\'' + row.deviceNumber + '\')">查看</a><br>';
                return p;
            }
        }},

        {field:'deviceId2',title:'开关',align:'center',width:80,formatter: function(value,row,index){

            if(row.deviceNumber!=null && row.deviceNumber.length >0) {
                var p = '<a style="margin-left: 5px;" href="javascript:void(0);" onclick="KG(\'' + row.deviceNumber + '\')">操作</a><br>';
                return p;
            }
        }},

        {field:'deviceId3',title:'视频',align:'center',width:80,formatter: function(value,row,index){
            if(row.deviceNumber!=null && row.deviceNumber.length >0) {
                var p = '<a style="margin-left: 5px;" href="javascript:void(0);" onclick="showVod(\'' + row.deviceNumber + '\')">查看</a><br>';
                return p;
            }
        }},

        {field:'flag',title:'车辆分类',align:'center',width:70,formatter: function(value,row,index){
            if (value == 0){
                return '自有车辆';
            } else if (value == 1) {
                return '已售车辆';
            } else {
                return '托管车辆';
            }
        }},

    ]]
});
$('#dg').datagrid('getPager').pagination({
    pageSize: 10,
    pageList: [10, 15, 20],
    beforePageText: '第',
    afterPageText: '页    共 {pages} 页',
    displayMsg: '当前显示 {from} - {to} 条记录   共 {total} 条记录'
});
//新建

//格式化预览图片字段
function showBigImage(imgUrl, obj){
    var x = $(obj).offset().top;
    var y = $(obj).offset().left;
    $("#showBigImage img").attr("src", imgUrl);
    $("#showBigImage").css("display", "block");
    $("#showBigImage").css("top", x);
    $("#showBigImage").css("left", y + 70);
}
function hideBigImage(){
    $("#showBigImage").css("display","none");
}
function DW(carid){
    var devicetype = <%=type%>;
    if(devicetype ==2 ) {

        window.open("/manage/resource/html/dw/baidu_dw.html?deviceNumber=" + carid);
    }else{
        window.open("/manage/resource/html/dw/baidu.html?deviceNumber=" + carid);

    }
}
function KG(carid){
//    alert(carid)
    var posturl = "http://localhost:8081/api/device/setOnOff";

//    var posturl = "http://www.myliferv.com/motorhome-api/api/device/setOnOff";


    $.post(posturl, {"deviceNumber":carid,"status":"car"}, function (data) {


    });

}
function showVod(carid ){
//    alert(carid)
    window.open("/manage/resource/html/dw/sp.html?deviceNumber="+carid);
}
</script>
</body>
</html>